package com.wenli.graduate2022.wenliGreenShop.service.servImpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wenli.graduate2022.wenliGreenShop.entity.Property;
import com.wenli.graduate2022.wenliGreenShop.repository.mapper.PropertyMapper;
import com.wenli.graduate2022.wenliGreenShop.service.servDao.PropertyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author HuangHai
 * @date 2021/10/8 18:06
 */
@Service
public class PropertyServImpl implements PropertyService {
    @Autowired
    PropertyMapper propertyMapper;

    @Override

    public List<Property> findAll() {
        return propertyMapper.findAll();
    }


    /**
     * 根据种类查找属性-------------------------
     * @param id
     * @return
     */
    @Override
    public List<Property> findByCategoryId(Integer id) {
        return propertyMapper.findByCategoryId(id);
    }

    @Override
    public IPage<Property> findByPage(Page page) {
        return propertyMapper.findByPage(page);

    }

    //查询单个种类的属性时不能用这个方法，要用上面的findByCategoryId才行
    @Override
    public Property findById(Integer id) {
        return propertyMapper.findById(id);
    }

    /**
     * 插入
     * @param property
     * @return
     */
    @Override
    public int insert(Property property) {
        return propertyMapper.insert(property);
    }

    @Override //修改
    public int update(Property property) {
        return propertyMapper.update(property);
    }

    @Override  //删除
    public int delete(Integer id) {
        return propertyMapper.delete(id);
    }

    @Override
    public List<Property> selectByCategoryName(String name) {

        return propertyMapper.selectByCategoryName(name);
    }

    @Override  //模糊查询
    public List<Property> findByName(String name) {
        return propertyMapper.findByName(name);
    }
}
